﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CompareDB
{
    public class FjCsManager
    {
        public List<FjCsTable> FirstTables { get; set; }
        public List<FjCsTable> SecondTables { get; set; }
        public string FirstConnection { get; set; }
        public string SecondConnection { get; set; }

        public FjCsManager(string firstConnection, string secondConnection)
        {
            FirstConnection = firstConnection;
            SecondConnection = secondConnection;
        }

        private void RipperTables()
        {
            var firstRipper = new FjCsRipper(FirstConnection);
            FirstTables = firstRipper.GetTables();

            var secondRipper = new FjCsRipper(SecondConnection);
            SecondTables = secondRipper.GetTables();
        }

        private bool RunCompare()
        {
            RipperTables();
            //ejecuta la comparacion de las tablas.
            return true;
        }

        /// <summary>
        /// Gets the tables compared.
        /// devuelve las dos tablas llenas y sus comparaciones ya realizadas.
        /// </summary>
        /// <returns></returns>
        public IList<FjCsTable> GetFirstTablesCompared()
        {
            var tablesResult = new List<FjCsTable>();

            if(RunCompare())
            {
                return FirstTables;
            }

            return tablesResult;
        }

        public IList<FjCsTable> GetSecondTablesCompared()
        {
            var tablesResult = new List<FjCsTable>();

            if (RunCompare())
            {
                return SecondTables;
            }

            return tablesResult;
        }
    }
}
